package org.teach.study.aigo.ai_go;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.nio.channels.FileLockInterruptionException;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.attribute.UserDefinedFileAttributeView;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Scanner;
import java.util.function.Consumer;

import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.SystemUtils;
import org.quincy.rock.core.os.CpuIdentifier;
import org.quincy.rock.core.os.CpuInfo;
import org.quincy.rock.core.util.DateUtil;
import org.quincy.rock.core.util.IOUtil;
import org.quincy.rock.core.util.RockUtil;
import org.quincy.rock.core.util.StringUtil;

import org.teach.study.aigo.ai_go.StudyRockMini;
/**
 * Hello world!
 *
 */



public class App 
{
    public static void main( String[] args ) throws IOException
    {
//    	System.out.println("请输入行数");
//    	Scanner sc = new Scanner(System.in);
//    	//返回int型
//    	int myrow = sc.nextInt();
    	String genshinString="原神启动！";
//    	System.out.print(StringUtils.repeat(" ", myrow-genshinString.length()));
    	
    	System.out.println(genshinString);
//    	System.out.println("0="+('0'+0));//asc2码
//    	List<Integer> mylist=StudyAlgorithm.findPrime2(100);
//    	mylist.forEach((n)->System.out.print(n+","));
//    	System.out.println(StudyAlgorithm.mysum(100));	//这是选中之后ctrl+/自动生成的注释
    /*
	int[] arr=new int[] {1,2,3,4,5,6,7};
	System.out.println(Arrays.toString(arr));
	System.out.println(Arrays.toString(StudyAlgorithm.reverse(arr)));
*/
    	//StudyAlgorithm.printDiamond1(9);
    	
    	/*
    	ATy aty = new ATy();//创建一个对象 
    	Thread t = new Thread(aty);//创建一个线程 
    	t.start();//线程开始  }
*/
    	int[] arr=new int[] {4,7,1,9,3,6,2};
    	StudyAlgorithm.bubbleSort(arr);
    }
    	
    
    public static void testRockMini(){
		if(RockUtil.isDupleStartup("ai-go")){
			
			throw  new UnsupportedOperationException("程序已经启动");		
			}
		//Thread.sleep(10000);
		
		Date  dt=DateUtil.parse("1565年9月12日", "yyyy年MM月dd日");
		//dt=DateUtil.getDateByWord("today", DateUtil.now());
		dt=DateUtil.getDateByWord("yesterday", dt);
		System.out.println(DateUtil.format(dt,"yyyy年MM月dd日"));
		//DateUtil.sleep(10000);
	}
    
    private static void testRock() {
    	String str=StringUtil.getUniqueIdentifierName("var");
    	str="d:\\"+str+".txt";
    	System.out.println(str);
    	str=StringUtil.str2hex("1234567");
    	System.out.println(str);
    	str=StringUtil.hex2Str(str);
    	System.out.println(str);
    	str=StringUtil.toCamelString("dept_name", '_');
    	System.out.println(str);
    	str=StringUtil.objName2DbName("dept_name", "f_", '_');
    	System.out.println(str);
    	str=StringUtil.dbName2ObjName(str, "f_", '_');
        System.out.println(str);
    }
    
    private static void Genshin_impact() {
    	System.out.println( "eclipse2023，启动！" );
    	System.out.println( "原神，启动！" );
	}
    
    private static void testLang() {

    	System.out.println( "Hello World!" );
    	String str="     ";
    	/*
    	if(StringUtils.isEmpty(str)){//这个方法还能判断空字符串,但是不能判断空格
    		System.out.println( "str is empty" );
    	}
    	if(StringUtils.isBlank(str)) {//這個方法判斷是不是空白，null是空字符串也是空白。
    		System.out.println( "str is blank" );
    	}
    	if(str==null||str.equals("")||str.trim().equals("")) {
    		System.out.println("eeeeeee");
    	}
    	System.out.println("6."+str+".");
    	
    	str=StringUtils.trim(str);
    	System.out.println("7."+str+".");
    	*/
    	Object[] arr=new Object[3];
    	arr[0]="123";
    	arr[1]="456";
    	arr[2]="9801";
    	str=StringUtils.joinWith(",", arr);
    	System.out.println(str);
//    	str=StringUtils.joinWith(",", new Object[]{"123","456","980"});
    	str=StringUtils.joinWith(",", "123","456","980");
    	System.out.println(str);
    	str=SystemUtils.getHostName();
    	System.out.println("主机名："+str);
    	str=SystemUtils.getUserName();
    	System.out.println("用户名："+str);
    	File file=SystemUtils.getJavaIoTmpDir();//系统的原始目录
    	file=SystemUtils.getUserDir();//用户文件在哪
    	System.out.println("文件，启动！"+file);
    	System.out.println("is java 8?"+SystemUtils.IS_JAVA_1_8);
    	System.out.println("java version:"+SystemUtils.JAVA_VERSION);
	}

    private static void testIO() throws IOException{
    	File dir=SystemUtils.getUserDir();
    	File srcfile=new File(dir,"pom.xml");//源文件路径
    	File destFile=new File("d:\\AE\\pom1.xml");//目标路径
    	FileUtils.copyFile(srcfile, destFile);
    	System.out.println("success:"+destFile.exists());
    	
//    	try {
//            List<String> lines = FileUtils.readLines(destFile, StandardCharsets.UTF_8);
//            //使用FileUtils的readLines()方法
//            lines.forEach(System.out::println);
//        }
//        catch (IOException e) {
//            e.printStackTrace();
//        }
//    	
    	FileInputStream fis=FileUtils.openInputStream(destFile);
    	try {
//			List<String> list=IOUtils.readLines(fis, Charset.forName("utf-8"));
    		List<String> list=IOUtils.readLines(fis, StringUtil.UTF_8);
    		
//    		for(int i=0,l=list.size();i<l;i++) {
//    			String str=list.get(i);
//    			System.out.println(str);
//    		}
//    		
//			for(String str:list) {
//				System.out.println(str);
//			}
    		
//    		list.forEach(new Consumer<String>() {
//
//				@Override
//				public void accept(String ele) {
//					System.out.println(ele);
//					
//				}
//			});//回调函数 函组   匿名内部类
    		
    		list.forEach((line)->System.out.println(line));//lambda表达式
    		
		} finally {
			//fis.close();//当fis空指针时候会出现空指针错误
			//IOUtils.close(fis);
			IOUtil.closeQuietly(fis);
			// TODO: handle finally clause
		}
    }


}


class ATy implements Runnable{ String wenben ="少壮不努力，老大敲代码\n-----By H4ckSo1di3r\n";  
public void run(){   
	for(int i=0; i<wenben.length();i++){   
		System.out.print(wenben.charAt(i));   
		try {    
			Thread.sleep(200);   
			} catch (InterruptedException e)
		{    e.printStackTrace();   
		}  
	}  //   另一种写法 把字符串先转换成字符串数组 再把依次打印//   
	char [] a =wenben.toCharArray();
	for(int i = 0;i<a.length;i++){
		System.out.print(a[i]);   
		try {    
			Thread.sleep(200);
			} catch (InterruptedException e) { 
				e.printStackTrace();  
				}
		}
	}
}